<?php
if(!defined('InDesign')) exit('Access Denied');

loadDatabase();

class User {



    function check_login() {
    }
    function pd_login($username, $password) {
        if($query=db::get_one("select * from ^user where username='$username'"){
            if($query['group']==0){     //Group of Disallow
                return -2;      //User is disallowed to login
            }
            if($query['password']==md5($password)){
                $this->pd_auth($query['uid']);
            }else{
                return -1;      //password wrong
            }
        }else{
            return -3;          //username wrong
        }
    }
    function pd_auth($uid) {
        loadModel('security/auth', 'storage/cookie');

        $this->login=1;
        $this->uid=$uid;

        MVCROOT::$Class['storage/cookie']->add('login', MVCROOT::$Class['security/auth']->auth('loginauth', $uid, 86400), 86400);
    }
}